<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <script type="text/javascript" src="./script/rem.js"></script>
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  <meta content="yes" name="apple-mobile-web-app-capable">
  <meta content="yes" name="apple-touch-fullscreen">
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
  <link rel="stylesheet" type="text/css" href="./css/style.css" />
  <script type="text/javascript" src="./script/jquery.min.js"></script>
  <script type="text/javascript" src="./script/aui-slide.js"></script>
  <script type="text/javascript" src="./script/jquery.min.js"></script>
  <script type="text/javascript" src="./script/doT.min.js"></script>
  <script type="text/javascript" src="./script/base.js"></script>
  <script type="text/javascript" src="./script/api.js"></script></head>
  <script type="text/javascript" src="./script/aui-tab.js" ></script>
  <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>

  <header class="head" style="padding-top:0.4rem;">
    <div class="head-l" tapmode onclick="closeWin()"><i class="fa fa-angle-left"></i></div>
    <h3>我的业绩</h3>
    <div class="head-r"></div>
  </header>
  <div class="head-d" style="padding-top:0.4rem;"></div>
  
  <div id="list">

    <div class="my-achievement-t mb20">
      <dl>
        <dt>张丽娜</dt>
        <dd>用户名：15646874847</dd>
      </dl>
      <img src="image/gril.png">
    </div>

    <div class="my-achievement mb20">
      <ul>
        <li>
          当月个人业绩
          <p>100</p>
        </li>
      </ul>
      <ul>
        <li>
          当月个人业绩
          <span>100</span>
        </li>
        <li>
          当月个人业绩
          <span>100</span>
        </li>
      </ul>
    </div>

  </div>


  <div class="list-text-r mb20">
    <ul>
      <li tapmode onclick="my_achievement_team()">
        查看我的团队
        <i class="fa fa-angle-right"></i>
      </li>
    </ul>
  </div>


</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/index.js"></script>

<script type="text/template" id="template">

  <div class="my-achievement-t mb20">
    <dl>
      <dt>{{=it.name}}</dt>
      <dd>用户名：{{=it.phone}}</dd>
    </dl>
    <img src="{{=it.avatar}}">
  </div>

  <div class="my-achievement mb20">
    <ul>
      <li>
        当月个人奖金
        <p>￥{{=it.prize_month}}</p>
      </li>
    </ul>
    <ul>
      <li>
        当月个人业绩
        <span>{{=it.p_month}}</span>
      </li>
      <li>
        当季个人业绩
        <span>{{=it.p_quarter}}</span>
      </li>
    </ul>
    <ul>
      <li>
        当月团队业绩
        <span>{{=it.t_month}}</span>
      </li>
      <li>
        当季团队业绩
        <span>{{=it.t_quarter}}</span>
      </li>
    </ul>
  </div>
</script>

<script type="text/javascript">

  apiready = function(){
    loadData();
  }

  function loadData(){
    var token = $api.getStorage('token');
    api.ajax({
      url: webAddress + '/api/user/sales/show',
      method: 'get',
      data: {
        values: {
        },
      },
      headers: {
        Authorization: 'Bearer ' + token,
        Accept: 'application/json',
      },
    },function(ret, err){
      if (ret) {
        // alert( JSON.stringify( ret ) );
        if (ret.data) {
          templateFun(ret.data);
        }
      } else {
        // alert( JSON.stringify( err ) );
      }
    });
  }


    // 模板赋值函数
    function templateFun(data){
      var template = $api.byId('template');
      var dotFn = doT.template(template.innerHTML);
      var html = dotFn(data);
      var list = $api.byId('list');
      $api.html(list, html);

    }

    function my_achievement_team() {
      api.openWin({
        name: 'my_achievement_team',
        url: './my_achievement_team.html',
      });
    }
    function closeWin(){
      api.closeWin({
      });
    }
  </script>
  </html>